﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace dbproj
{
    public partial class Form7 : Form
    {
        public string SID;
        public Form7(string sId)
        {
            InitializeComponent();
            SID = sId; // 传入登录学生的ID
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("输入不能为空，请检查！", "提示",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                string sql = $"Insert into Message values('{SID}','{textBox1.Text}')";
                //MessageBox.Show(sql);
                Dao dao = new Dao();
                int i = dao.Execute(sql);
                if (i > 0)
                {
                    MessageBox.Show("插入成功");
                    textBox1.Text = null;

                }
            }
        }
    }
}
